﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace 期末作业
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

     

        protected override bool ProcessCmdKey(ref System.Windows.Forms.Message msg, System.Windows.Forms.Keys keyData)
        {
            switch (keyData)
            {
                case Keys.Escape:
                    this.Close();//esc关闭窗体
                    break;
            }
            return false;

        }
        private void button1_Click_1(object sender, EventArgs e)
        {
            string name = txtName.Text;
            string pwd = txtPass.Text;
            if (txtName.Text == "沈曼园" && txtPass.Text == "2018131437")
            {
                MessageBox.Show("登入成功！");
                new Form2().Show();
            }
            else
            {
                MessageBox.Show("登入失败！");
            }

        }


        public static bool isLogin { get; set; }

        public static string userName { get; set; }

        private void button2_Click(object sender, EventArgs e)
        {
            txtName.Text = "";
            txtPass.Text = "";
        }
        //密码输入完成后实现敲击enter键触发登录按钮
        private void txtPass_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                this.button1_Click(sender, e);
            }
        }

        private void button1_Click(object sender, KeyEventArgs e)
        {
            throw new NotImplementedException();
        }
        //实现按enter键使焦点转移到下一文本框，与tab键通用
        private void txtName_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == (char)Keys.Enter)
            {
                SendKeys.Send("{tab}");
            }
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

     
        private void button2_Click_1(object sender, EventArgs e)
        {

        }

        private void label3_Click(object sender, EventArgs e)
        {

        }

        private void txtPass_TextChanged(object sender, EventArgs e)
        {

        }

        private void txtName_TextChanged(object sender, EventArgs e)
        {

        }

        private void label2_Click(object sender, EventArgs e)
        {

        }

        private void label1_Click(object sender, EventArgs e)
        {

        }
    }
}
